package com.xian.demo;

public class Test1 {
    public static void main(String[] args) {
        //需求：计算1-n的和
        System.out.println(add(3));

    }

    public static int add(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i;
        }
        return sum;
    }
}
